package mamikeji.liaowa.ui.fragment.right_menu;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import mamikeji.liaowa.R;

/**
 * Created by 廉冲-android开发 on 2017/8/5.
 */
public class RightFragment extends Fragment implements View.OnClickListener {
//    private static final String TAG = "RightFragment";
    View mView;
//    @BindView(R.id.imageView_right_back)
//    ImageView imageViewRightBack;
//    @BindView(R.id.imageView_right_headerimg)
//    public SimpleDraweeView imageViewRightHeaderimg;
//    @BindView(R.id.textView_right_user_name)
//    public TextView textViewRightUserName;
//    @BindView(R.id.textView_right_babytime)
//    public TextView textViewRightBabytime;
//    @BindView(R.id.textView_right_every_diary)
//    public TextView textViewRightEveryDiary;
//    @BindView(R.id.relativeLayout_rightmenu_diary)
//    RelativeLayout relativeLayoutRightmenuDiary;
//    @BindView(R.id.textView_right_clock_num)
//    public TextView textViewRightClockNum;
//    @BindView(R.id.relativeLayout_right_clock)
//    RelativeLayout relativeLayoutRightClock;
//    @BindView(R.id.textView_right_collection_num)
//    public TextView textViewRightCollectionNum;
//    @BindView(R.id.relativeLayout_rightmenu_mycollection)
//    RelativeLayout relativeLayoutRightmenuMycollection;
//    @BindView(R.id.relativeLayout_rightmenu_mamiQ)
//    RelativeLayout relativeLayoutRightmenuMamiQ;
//    @BindView(R.id.relativeLayout_rightmenu_event)
//    RelativeLayout relativeLayoutRightmenuEvent;
//    @BindView(R.id.relativeLayout_rightmenu_myshare)
//    RelativeLayout relativeLayoutRightmenuMyshare;
//    @BindView(R.id.relativeLayout_rightmenu_think)
//    RelativeLayout relativeLayoutRightmenuThink;
//    @BindView(R.id.relativeLayout_rightmenu_set)
//    RelativeLayout relativeLayoutRightmenuSet;
//    @BindView(R.id.frameLayout_rightmenu_notice)
//    FrameLayout frameLayoutRightmenuNotice;
//    @BindView(R.id.textView_right_follow)
//    public TextView textViewRightFollow;
//    @BindView(R.id.textView_right_fans)
//    public TextView textViewRightFans;
//    @BindView(R.id.relativeLayout_right_user)
//    RelativeLayout relativeLayoutRightUser;
//    @BindView(R.id.relativeLayout_right_login)
//    RelativeLayout relativeLayoutRightLogin;
//    @BindView(R.id.textView_rightmenu_msg)
//    TextView textViewRightmenuMsg;
//
//    @BindView(R.id.textView_right_1)
//    TextView textViewRight1;
//    @BindView(R.id.textView_right_2)
//    TextView textViewRight2;
//    @BindView(R.id.textView_right_3)
//    TextView textViewRight3;
//    @BindView(R.id.textView_right_4)
//    TextView textViewRight4;
//    @BindView(R.id.textView_right_5)
//    TextView textViewRight5;
//    @BindView(R.id.textView_right_6)
//    TextView textViewRight6;
//    @BindView(R.id.textView_right_7)
//    TextView textViewRight7;
//    @BindView(R.id.relativeLayout_right_chart)
//    RelativeLayout relativeLayout_right_chart;
//
//    float[][] randomNumbersTab;
//    @BindView(R.id.linearLayout_rightmenu_guanzhu)
//    LinearLayout linearLayoutRightmenuGuanzhu;
//    @BindView(R.id.linearLayout_rightmenu_usermsg)
//    LinearLayout linearLayoutRightmenuUsermsg;
//    @BindView(R.id.linearLayout_rightmenu_fans)
//    LinearLayout linearLayoutRightmenuFans;
//    @BindView(R.id.linearLayout_chart_right_datetime)
//    LinearLayout linearLayoutChartRightDatetime;
//    @BindView(R.id.view_right_dateTime_null)
//    View viewRightDateTimeNull;
//
//    private LineChartView chartRightDatetime;
//    private LineChartData data;
//    private List<TextView> textViewList;
//
//    //分享弹框
//    private Dialog dialog_share;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_right_menu, container, false);
//        ButterKnife.bind(this, mView);
//
//        init();
//        initData();
//        getDialogShare();
        return mView;
    }

//    /**
//     * 实例化控件
//     */
//    private void init() {
//        if (ForPreference.getString(ForContents.USER_PHONE).equals("") || ForPreference.getString(ForContents.USER_PHONE) == null) {
//            relativeLayoutRightLogin.setVisibility(View.VISIBLE);
//            relativeLayoutRightUser.setVisibility(View.GONE);
//        } else if (ForPreference.getString(ForContents.USER_CODE).equals("") || ForPreference.getString(ForContents.USER_CODE) == null) {
//            relativeLayoutRightLogin.setVisibility(View.VISIBLE);
//            relativeLayoutRightUser.setVisibility(View.GONE);
//        } else {
//            resetViewport();
//            getTimeData();
//            relativeLayoutRightLogin.setVisibility(View.GONE);
//            relativeLayoutRightUser.setVisibility(View.VISIBLE);
//        }
//    }
//
//    public void toast (boolean bool){
////        //设置头像
////        imageViewRightHeaderimg
////                .setImageURI(Uri.parse(ForPreference.getString(ForContents.USER_HEADERURL)));
////        //设置昵称
////        textViewRightUserName.setText(ForPreference.getString(ForContents.USER_NAME));
////        textViewRightBabytime.setText(ForPreference.getString(ForContents.WA_DAY));
////
////        textViewRightEveryDiary.setText(ForPreference.getInt(ForContents.USER_every_diary) + "");
////        textViewRightClockNum.setText(ForPreference.getInt(ForContents.APP_CLOCK_COUNT) + "");
////        textViewRightCollectionNum.setText(ForPreference.getInt(ForContents.USER_COLLECTION) + "");
////        textViewRightFollow.setText(ForPreference.getInt(ForContents.USER_follow) + "");
////        textViewRightFans.setText(ForPreference.getInt(ForContents.USER_fans) + "");
//
//    }
//
//    /**
//     * 初始化控件
//     */
//    private void initData() {
//        /*
//         * 必须事先在assets底下创建一fonts文件夹 并放入要使用的字体文件(.ttf)
//         * 并提供相对路径给creatFromAsset()来创建Typeface对象
//         */
//        Typeface fontFace = Typeface.createFromAsset(getContext().getAssets(),
//                "fonts/main_text_css.ttf");
//        textViewRightmenuMsg.setTypeface(fontFace);
//
//        //设置头像
//        imageViewRightHeaderimg
//                .setImageURI(Uri.parse(ForPreference.getString(ForContents.USER_HEADERURL)));
//        //设置昵称
//        textViewRightUserName.setText(ForPreference.getString(ForContents.USER_NAME));
//
//        ForLog.i("WA_DAYWA_DAY", ForPreference.getString(ForContents.WA_DAY));
//        textViewRightBabytime.setText(ForPreference.getString(ForContents.WA_DAY));
//
//        textViewRightEveryDiary.setText(ForPreference.getInt(ForContents.USER_every_diary) + "");
//        textViewRightClockNum.setText(ForPreference.getInt(ForContents.APP_CLOCK_COUNT) + "");
//        textViewRightCollectionNum.setText(ForPreference.getInt(ForContents.USER_COLLECTION) + "");
//        textViewRightFollow.setText(ForPreference.getInt(ForContents.USER_follow) + "");
//        textViewRightFans.setText(ForPreference.getInt(ForContents.USER_fans) + "");
//
//        textViewList = new ArrayList<>();
//        textViewList.add(textViewRight1);
//        textViewList.add(textViewRight2);
//        textViewList.add(textViewRight3);
//        textViewList.add(textViewRight4);
//        textViewList.add(textViewRight5);
//        textViewList.add(textViewRight6);
//        textViewList.add(textViewRight7);
//    }
//
//    @OnClick({
//            R.id.relativeLayout_rightmenu_myshare_login,
//            R.id.relativeLayout_rightmenu_think_login,
//            R.id.relativeLayout_rightmenu_set_login,
//            R.id.relativeLayout_right_login_btn,
//
//            R.id.imageView_right_back,
//            R.id.frameLayout_rightmenu_notice,
//            R.id.imageView_right_headerimg,
//            R.id.relativeLayout_rightmenu_diary,
//            R.id.relativeLayout_right_clock,
//
//            R.id.relativeLayout_rightmenu_mycollection,
//            R.id.relativeLayout_rightmenu_mamiQ,
//            R.id.relativeLayout_rightmenu_event,
//            R.id.relativeLayout_rightmenu_myshare,
//            R.id.relativeLayout_rightmenu_think,
//
//            R.id.relativeLayout_rightmenu_set,
//            R.id.linearLayout_rightmenu_guanzhu,
//            R.id.linearLayout_rightmenu_usermsg,
//            R.id.linearLayout_rightmenu_fans
//    })
//    public void onViewClicked(View view) {
//        Intent mIntent = null;
//        switch (view.getId()) {
//            case R.id.relativeLayout_right_chart:
//                mIntent = new Intent(getContext(), TimeDateActivity.class);
//                break;
//            case R.id.imageView_right_back:
//                ((MainActivity) getActivity()).CloseMenu();
//                break;
//            case R.id.imageView_right_headerimg:
//                mIntent = new Intent(getContext(), UserMSGActicity.class);
//                break;
//            case R.id.frameLayout_rightmenu_notice:
//                mIntent = new Intent(getContext(), UserNoticeActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_diary:
//                mIntent = new Intent(getContext(), EveryDayDiaryActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_mycollection:
//                mIntent = new Intent(getContext(), UserCollectionActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_mamiQ:
//                mIntent = new Intent(getContext(), BabyMomCircleActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_event:
//                mIntent = new Intent(getContext(), MyCircleActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_myshare_login:
//            case R.id.relativeLayout_rightmenu_myshare:
//                dialog_share.show();
//                break;
//            case R.id.relativeLayout_rightmenu_think_login:
//            case R.id.relativeLayout_rightmenu_think:
//                mIntent = new Intent(getContext(), UserFeedbackActivity.class);
//                break;
//            case R.id.relativeLayout_rightmenu_set_login:
//            case R.id.relativeLayout_rightmenu_set:
//                mIntent = new Intent(getContext(), SetActivity.class);
//                break;
//            case R.id.relativeLayout_right_clock:
//                mIntent = new Intent(getContext(), ClockListActivity.class);
//                break;
//            case R.id.relativeLayout_right_login_btn:
//                mIntent = new Intent(getContext(), LoginActivity.class);
//                break;
//            case R.id.linearLayout_rightmenu_guanzhu:
//                mIntent = new Intent(getContext(), UserFollowActivity.class);
//                mIntent.putExtra(ForContents.USER_follow, ForPreference.getString(ForContents.USER_CODE));
//                mIntent.putExtra("type", true);
//                mIntent.putExtra(ForContents.USER_NAME, ForPreference.getString(ForContents.USER_NAME));
//            case R.id.linearLayout_rightmenu_fans:
//                mIntent = new Intent(getContext(), UserFollowActivity.class);
//                mIntent.putExtra(ForContents.USER_follow, ForPreference.getString(ForContents.USER_CODE));
//                mIntent.putExtra("type", false);
//                mIntent.putExtra(ForContents.USER_NAME, ForPreference.getString(ForContents.USER_NAME));
//                break;
//            case R.id.linearLayout_rightmenu_usermsg:
//                break;
//        }
//        if (mIntent != null) {
//            startActivity(mIntent);
//        }
//    }
//
//    /**
//     * 获取日期图数据
//     */
//    public void getTimeData() {
//        //参数集合
//        Map<String, String> formMap = new HashMap<String, String>();
//        formMap.put(HttpKey.TIME_DATE_USERCODE, ForPreference.getString(ForContents.USER_CODE));
//        ForHttp.setMsg(HttpApi.ROOT_PATH + HttpApi.DATETIME_DATA, formMap, new StringCallback() {
//            @Override
//            public void onError(Request request, Exception e) {
//                ForLog.i(TAG, e.getMessage());
//                ForToast.showToast(R.string.intent_error);
//            }
//
//            @Override
//            public void onResponse(String response) {
//                ForLog.i(TAG, response);
//                try {
//                    JSONObject jsonObject = new JSONObject(response);
//                    String status = jsonObject.getString(HttpKey.STATUS);
//                    if ("200".equals(status)) {
//                        TimeDataBean timeDataBean = new Gson().fromJson(response, TimeDataBean.class);
//
//                        getChart_dayData(timeDataBean.getMaxnaturalday() + "", timeDataBean.getState() + "", timeDataBean.getDatetime());
//                    } else {
//                        ForToast.showToast(jsonObject.getString(HttpKey.MESSAGE));
//                    }
//                } catch (JSONException e) {
//                    e.printStackTrace();
//                }
//            }
//        });
//    }
//
//    /**
//     * 获取折线图 日数据
//     */
//    public void getChart_dayData(String week, String states, final String time) {
//        //参数集合
//        Map<String, String> formMap = new HashMap<String, String>();
//        formMap.put(HttpKey.TIME_DATE_USERCODE, ForPreference.getString(ForContents.USER_CODE));
//        formMap.put(HttpKey.TIME_DATE_WEEK, week);
//        formMap.put(HttpKey.TIME_DATE_STATES, states);
//        ForHttp.setMsg(HttpApi.ROOT_PATH + HttpApi.DATETIME_DAY, formMap, new StringCallback() {
//            @Override
//            public void onError(Request request, Exception e) {
//                ForLog.i(TAG, e.getMessage());
//                ForToast.showToast(R.string.intent_error);
//            }
//
//            @Override
//            public void onResponse(String response) {
//                ForLog.i(TAG + "day", response);
//                try {
//                    JSONObject jsonObject = new JSONObject(response);
//                    String status = jsonObject.getString(HttpKey.STATUS);
//                    if ("200".equals(status)) {
//                        TimeData_dayBean timeData_dayBean = new Gson().fromJson(response, TimeData_dayBean.class);
//
//                        if (timeData_dayBean.getDaycategoryList1() != null) {
//                            if (timeData_dayBean.getDaycategoryList1().size() > 0) {
//                                for (int i = 0; i < 7; i++) {
//                                    int num = timeData_dayBean.getDaycategoryList1().size();
//                                    if (i < num) {
//                                        String newStr = timeData_dayBean.getDaycategoryList4().get(i).getDatetimes()
//                                                .substring(6, timeData_dayBean.getDaycategoryList4().get(i).getDatetimes().length() - 2);
//                                        Long datatime = Long.valueOf(newStr);
//
//                                        String weekStr = timeData_dayBean.getDaycategoryList1().get(i).getWeekname()
//                                                .substring(2, timeData_dayBean.getDaycategoryList1().get(i).getWeekname().length());
//                                        if (getFormatedDateTime("yyyy-MM-dd", datatime).equals(time)) {
//                                            textViewList.get(i).setText("今");
//                                        } else {
//                                            textViewList.get(i).setText(weekStr);
//                                        }
//                                    } else {
//                                        textViewList.get(i + 14).setText("-");
//                                    }
//                                }
//
//                                randomNumbersTab = new float[1][7];
//                                for (int j = 0; j < 7; j++) {
//                                    if (timeData_dayBean.getDaycategoryList4().size() != 7) {
//                                        if (j >= timeData_dayBean.getDaycategoryList4().size()) {
//                                            randomNumbersTab[0][j] = (float) 0;
//                                        } else {
//                                            randomNumbersTab[0][j] = (float) timeData_dayBean.getDaycategoryList4().get(j).getSum();
//                                        }
//                                    } else {
//                                        randomNumbersTab[0][j] = (float) timeData_dayBean.getDaycategoryList4().get(j).getSum();
//                                    }
//                                }
//
//                                //划线
//                                generateData();
//                            }
//                        }
//                    } else {
//                        ForToast.showToast(jsonObject.getString(HttpKey.MESSAGE));
//                    }
//                } catch (JSONException e) {
//                    e.printStackTrace();
//                }
//            }
//        });
//    }
//
//    private void resetViewport() {
//        chartRightDatetime = new LineChartView(getContext());
//        linearLayoutChartRightDatetime.addView(chartRightDatetime);
//
//        Viewport viewport = new Viewport(0, 100, 7, -100);
//        chartRightDatetime.setMaximumViewport(viewport);
//        chartRightDatetime.setCurrentViewport(viewport);
//    }
//
//    private void generateData() {
//        List<Line> lines = new ArrayList<Line>();
//        List<PointValue> values = new ArrayList<PointValue>();
//        for (int j = 0; j < 7; ++j) {
//            values.add(new PointValue(j, randomNumbersTab[0][j]));
//        }
//
//        if (randomNumbersTab[0][0] <= 0 &&
//                randomNumbersTab[0][1] <= 0 &&
//                randomNumbersTab[0][2] <= 0 &&
//                randomNumbersTab[0][3] <= 0 &&
//                randomNumbersTab[0][4] <= 0 &&
//                randomNumbersTab[0][5] <= 0 &&
//                randomNumbersTab[0][6] <= 0) {
//            viewRightDateTimeNull.setVisibility(View.VISIBLE);
//        } else {
//            viewRightDateTimeNull.setVisibility(View.GONE);
//        }
//
//        Line line = new Line(values);
//        line.setColor(Color.parseColor("#ffffff"));//设置线的颜色
//        line.setHasLabels(false);//是否加标签
//        line.setHasLines(true);//是否有线
//        line.setHasPoints(false);//是否有圆点
//        line.setCubic(false);
//
//        line.setFilled(true);
//        line.setStrokeWidth(1);
//
//        lines.add(line);
//
//        data = new LineChartData(lines);
//
//        data.setBaseValue(Float.NEGATIVE_INFINITY);
//        data.setValueLabelBackgroundColor(Color.BLUE);// 设置数据背景颜色
//        data.setValueLabelBackgroundEnabled(true);// 设置是否有数据背景
//        chartRightDatetime.setZoomEnabled(false);//设置是否支持缩放
//        chartRightDatetime.setLineChartData(data);
//    }
//
//    public static String getFormatedDateTime(String dateFormat, long dateTime) {
//        SimpleDateFormat sDateFormat = new SimpleDateFormat(dateFormat);
//        return sDateFormat.format(new Date(dateTime + 0));
//    }
//
    @Override
    public void onClick(View view) {
//        switch (view.getId()) {
//            case R.id.linearLayout_share_wechatFriend:
//                dialog_share.hide();
//                ShareWeb(SHARE_MEDIA.WEIXIN);
//                break;
//            case R.id.linearLayout_share_wechatCircle:
//                dialog_share.hide();
//                ShareWeb(SHARE_MEDIA.WEIXIN_CIRCLE);
//                break;
//            case R.id.linearLayout_share_tencentCircle:
//                dialog_share.hide();
//                ShareWeb(SHARE_MEDIA.QZONE);
//                break;
//        }
    }
//
//    /**
//     * 分享弹框
//     */
//    public void getDialogShare() {
//        dialog_share = new Dialog(getContext(), R.style.ActionSheetDialogStyle);
//        View view = LayoutInflater.from(getContext()).inflate(R.layout.diglog_set_shape, null);
//        dialog_share.setContentView(view);
//        Window dialogWindow = dialog_share.getWindow();
//        dialogWindow.setGravity(Gravity.BOTTOM);
//        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
//        lp.y = 0;
//        lp.width = getResources().getDisplayMetrics().widthPixels; // 宽度
//        dialogWindow.setAttributes(lp);
//
//        LinearLayout linearLayout_share_wechatFriend = (LinearLayout) view.findViewById(R.id.linearLayout_share_wechatFriend);
//        LinearLayout linearLayout_share_wechatCircle = (LinearLayout) view.findViewById(R.id.linearLayout_share_wechatCircle);
//        LinearLayout linearLayout_share_tencentCircle = (LinearLayout) view.findViewById(R.id.linearLayout_share_tencentCircle);
//
//        linearLayout_share_wechatFriend.setOnClickListener(this);
//        linearLayout_share_wechatCircle.setOnClickListener(this);
//        linearLayout_share_tencentCircle.setOnClickListener(this);
//    }
//
//    /**
//     * 分享回调
//     *
//     * @param anEnum
//     */
//    private void ShareWeb(Enum anEnum) {
//        UMImage thumb = new UMImage(getContext(), R.mipmap.ic_launcher);
//        UMWeb web = new UMWeb("https://www.baidu.com");
//        web.setThumb(thumb);
//        web.setDescription("为亿万用户提供个性化的每日育儿指导，不用搜索，不用导航，轻轻一点，每日育儿即可直接呈现");
//        web.setTitle("下载撩娃APP，让育儿如此简单！");
//        new ShareAction(getActivity()).withMedia(web).setPlatform((SHARE_MEDIA) anEnum).setCallback(new UMShareListener() {
//            @Override
//            public void onStart(SHARE_MEDIA share_media) {
//                ForToast.showToast("后台正在玩儿命加载~~~");
//            }
//
//            @Override
//            public void onResult(SHARE_MEDIA share_media) {
//                ForToast.showToast("分享成功！");
//            }
//
//            @Override
//            public void onError(SHARE_MEDIA share_media, Throwable throwable) {
//                ForLog.i("throwable", "" + throwable.toString());
//                ForToast.showToast("分享失败！");
//            }
//
//            @Override
//            public void onCancel(SHARE_MEDIA share_media) {
//                ForToast.showToast("取消分享！");
//            }
//        }).share();
//    }
}
